<%@ page language="java" contentType="text/html;charset=UTF-8"%>
<%@ include file="/commons/taglibs.jsp"%>
<%@ include file="/commons/commonEdit.jsp"%>
<%@ include file="/commons/validation.jsp"%>
<%@ include file="/commons/dateTime.jsp" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>创建派工单</title>
<script language="JavaScript" type="text/javascript"
	src="${ctx}/scripts/div/common.js"></script>
<script type="text/javascript">

  /**
  *创建派工单
  */
  function addDispatchForm(){
   if(document.getElementById("btn1_42").className=='buttonUnEditMiddle'){
	       return false;
	}
    var isTrue=$("editForm").fireEvent("onSubmit");
    if(isTrue){
    document.getElementById("btn1_42").className='buttonUnEditMiddle';
     document.getElementById("editForm").submit();
    }
  }

  /**
  *预览派工单
  */
  function dispatchFormView(){
   if(document.getElementById("btn1_52").className=='buttonUnEditMiddle'){
	       return false;
	}
	var id=document.getElementById("dispatchFormId").value;
	var url = "${ctx}/applets/appletShow.jsp?reportName=dispatchForm&dispatchFormId="+id;
    window.open (url);
  }

  /**
  *费用清单
  */
  function chargeItemManage(){
   if(document.getElementById("btn1_62").className=='buttonUnEditMiddle'){
	       return false;
	}
	var id=document.getElementById("dispatchFormId").value;
	var url = "${ctx}/customerService_dispatchFormAction.do?method=navigateChargeItemManage&dispatchFormId="+id;
		top.windowOpen(url, "chargeItemManage", "费用清单", 350, 850,true,"chargeItemManage");

  }

  function selectPerson(){
  var url = "${ctx}/common_employeeQuery.do?method=initSelectPsrsonMain&frameName=addDispatchForm&callBack=selectPersonCallBack&multiple=false";
		top.windowOpen(url, "selectPerson", "", 530, 700,true,"selectPerson");

  }

  function selectPersonCallBack(info){
  var onePerson= new Array();

  onePerson=info.split(";");

    for (i=0;i<onePerson.length ;i++ )
    {
     var oneAttribute= new Array();
     oneAttribute=onePerson[i].split(",");

        var userId=oneAttribute[0];
        var employeeName=oneAttribute[1];
        var deptId=oneAttribute[2];
        var dept=oneAttribute[3];


document.getElementById("deptName").value=dept;
document.getElementById("deptId").value=deptId;
document.getElementById("receiver").value=employeeName;

    }


  }

   function selectDept(){
  var url = "${ctx}/common_employeeQuery.do?method=getAllDeptList&frameName=addDispatchForm&callBack=selectDeptCallBack&multiple=false";
		top.windowOpen(url, "selectPerson", "", 530, 700,true,"selectPerson");

  }

  function selectDeptCallBack(info){
  var oneDept= new Array();

  oneDept=info.split(",");
  document.getElementById("deptName").value=oneDept[1];
  if(document.getElementById("deptId").value!=oneDept[0]){
  document.getElementById("receiver").value="";
  }
   document.getElementById("deptId").value=oneDept[0];
  }


</script>
</head>

<body>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td colspan="2" class="window_head_outBg"><table border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td><span class="window_head_intext"><img src="${ctx}/images/ico_Advance.gif" align="absmiddle" /> 创建派工单</span></td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td colspan="2" class="aux_header_line_1"></td>
  </tr>
  <tr>
    <td colspan="2" class="aux_header_line_2"></td>
  </tr>
  <tr>
    <td colspan="2" class="content"><table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td class="aux_outtable_color"><table width="100%" border="0" cellpadding="0" cellspacing="1" class="aux_intable_color">
           <form id="editForm" name="editForm" method="post" action="${ctx}/customerService_dispatchFormAction.do?method=addDispatchForm" class="required-validate">
          <input type="hidden" name="customerEventId" value="${customerEventId}">
           <input type="hidden" name="dispatchFormId" value="${dispatchFormVO.keyword}">
           <input type="hidden" name="houseId" value="${dispatchFormVO.houseId}">

           <input type="hidden" name="deptId" value="${dispatchFormVO.deptId}">

          <tr>
            <td class="aux_intable_td1">派工单号：</td>
            <td class="aux_intable_td2">${dispatchFormVO.dispatchNo}</td>
            <td class="aux_intable_td1">紧急程度：</td>
            <td class="aux_intable_require">
            <pms:unitedSelect id="emergencyDegreeId"
   								name="emergencyDegreeId"
   								style="width:110px;"
   								optionLabel="name"
   								optionValue="keyword"
   								className="select-one-required"
   								dataList="${emergencyDegreeList}"
   								value="${dispatchFormVO.emergencyDegreeId}"
   								selectText="请选择...">
   				</pms:unitedSelect>

            </td>
          </tr>
          <tr>
            <td class="aux_intable_td1">房 号： </td>
            <td class="aux_intable_td2">${dispatchFormVO.houseNumber}<input type="hidden" name="houseNumber" value="${dispatchFormVO.houseNumber}"></td>
            <td class="aux_intable_td1">接单部门：</td>
            <td class="aux_intable_require"><table border="0" cellspacing="0" cellpadding="0">
                <tr>
                  <td><input name="deptName" readOnly type="text" class="required" value="${dispatchFormVO.deptName}" size="16" /></td>
                  <td width="4">&nbsp;</td>
                  <td><a href="#"  onClick="selectDept();"onFocus="this.blur()"><img src="${ctx}/images/ico_cz.gif" width="16" height="16" border="0" /></a></td>
                </tr>
            </table></td>
          </tr>
          <tr>
            <td class="aux_intable_td1">详细地址： </td>
            <td class="aux_intable_td2">${dispatchFormVO.fullAddress}<input type="hidden" name="fullAddress" value="${dispatchFormVO.fullAddress}"></td>
            <td class="aux_intable_td1">接单人：</td>
            <td class="aux_intable_td2"><table border="0" cellspacing="0" cellpadding="0">
                <tr>
                  <td><input name="receiver" readOnly type="text" class="inputtext" value="${dispatchFormVO.receiver}" size="16" maxLength="36"/></td>
                  <td width="4">&nbsp;</td>
                  <td><a href="#"  onClick="selectPerson();"onFocus="this.blur()"><img src="${ctx}/images/ico_cz.gif" width="16" height="16" border="0" /></a></td>
                </tr>
            </table></td>
          </tr>
          <tr>
            <td class="aux_intable_td1">联系人：</td>
            <td class="aux_intable_require">
            	<input name="contact" type="text"
            		class="required validate-char"
            		validateChar="\\<\\>\\'\\'“”~!#$%^&*=+[\\]{};:/?`|！·￥…\\；：。，》《[]"
            		value="${dispatchFormVO.contact}"
            		size="16" maxLength="36"/></td>
            <td class="aux_intable_td1">派单人：</td>
            <td class="aux_intable_td2">${dispatchFormVO.dispatchMan}
            <input type="hidden" name="dispatchMan" value="${dispatchFormVO.dispatchMan}">
            </td>
          </tr>
          <tr>
            <td class="aux_intable_td1">联系电话：</td>
            <td width="10%" class="aux_intable_td2"><input name="linkPhone" type="text" class="inputtext validate-char" value="${dispatchFormVO.linkPhone}" size="16" maxLength="36"/></td>
             <td valign="top" class="aux_intable_td1">派单时间：</td>
            <td class="aux_intable_td2"><fmt:formatDate value="${dispatchFormVO.dispatchTime}" pattern="yyyy-MM-dd HH:mm"/>
            <input type="hidden" name="dispatchTime" value="${dispatchFormVO.dispatchTime}"></td>
          </tr>
          <tr>
            <td class="aux_intable_td1">预约时间：</td>
            <td class="aux_intable_td2"><table border="0" cellspacing="0" cellpadding="0">
                <tr>
                  <td><input name="appointment" type="text" class="validate-dateTime-yyyy-mm-dd-HH:mm" value="<fmt:formatDate value='${dispatchFormVO.appointment}' pattern='yyyy-MM-dd HH:mm'/>" size="16" /></td>
                  <td width="4">&nbsp;</td>
                  <td><img id="appointmentImageBtn" src="${ctx}/images/ico_clock.gif" width="20" height="20" /></td>
                </tr>
            </table></td>
            <td valign="top" class="aux_intable_td1"  rowspan="2">备注：</td>
            <td valign="top" class="aux_intable_td2"  rowspan="2">
              <textarea name="remark" cols="20" rows="5" class="max-length-200">${dispatchFormVO.remark}</textarea></td>

          </tr>
		  <tr>
            <td valign="top" class="aux_intable_td1">服务内容：</td>
            <td class="aux_intable_require_more"><textarea name="serviceContent" cols="20" rows="3" class="required max-length-200">${dispatchFormVO.serviceContent}</textarea>            </td>
            	  </tr>

        </table>
        </form>

        </td>
      </tr>
    </table></td>
  </tr>
  <tr>

    <td class="window_footer"><table border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td><table border="0" cellpadding="0" cellspacing="0">
            <tr>
              <td class="buttonOffLeft" id="btn1_61"></td>
              <td class="buttonOffMiddle" id="btn1_62" onClick="chargeItemManage();" onMouseOver="btn_change_over(6)" onMouseOut="btn_change_out(6)" onBlur="btn_change(6)"><img id="img_btn1_62" src="${ctx}/images/ico_zxsf_sq.gif" alt="" width="14" height="14" border="0" align="absbottom" />费用清单</td>
              <td class="buttonOffRight" id="btn1_63"></td>
            </tr>
        </table></td>

		<td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
		<td class="btn_between_space"></td>

		<td><table border="0" cellpadding="0" cellspacing="0">
            <tr>
              <td class="buttonOffLeft" id="btn1_41"></td>
              <td class="buttonOffMiddle" id="btn1_42" onClick="addDispatchForm();" onMouseOver="btn_change_over(4)" onMouseOut="btn_change_out(4)" onBlur="btn_change(4)"><img id="img_btn1_42" src="${ctx}/images/ico_house_fwxs.gif" alt="" width="14" height="14" border="0" align="absbottom" /> 创 建</td>
              <td class="buttonOffRight" id="btn1_43"></td>
            </tr>
        </table></td>

		<td class="btn_between_space"></td>
		<td><table border="0" cellpadding="0" cellspacing="0">
            <tr>
			  <td class="buttonOffLeft" id="btn1_51"></td>
              <td class="buttonOffMiddle" id="btn1_52" onClick="dispatchFormView();" onMouseOver="btn_change_over(5)" onMouseOut="btn_change_out(5)" onBlur="btn_change(5)"><img id="img_btn1_52" src="${ctx}/images/ico_Confirmation.gif" alt="" width="14" height="14" border="0" align="absbottom" /> 预 览</td>
              <td class="buttonOffRight" id="btn1_53"></td>
            </tr>
        </table></td>
        <td class="btn_between_space"></td>
        <td><table border="0" cellpadding="0" cellspacing="0">
            <tr>
              <td class="buttonOffLeft" id="btn1_31"></td>
              <td class="buttonOffMiddle" id="btn1_32" onClick="windowClose();" onMouseOver="btn_change_over(3)" onMouseOut="btn_change_out(3)" onBlur="btn_change(3)"><img src="${ctx}/images/ico_cancel.gif" alt="" width="14" height="14" border="0" align="absbottom" /> 关 闭</td>
              <td class="buttonOffRight" id="btn1_33"></td>
            </tr>
        </table></td>
      </tr>
    </table>
    <p>&nbsp;</p></td>
  </tr>
</table>
</body>
<script type="text/javascript">

 document.getElementById("emergencyDegreeId").value='${dispatchFormVO.emergencyDegreeId}';

   if(document.getElementById("dispatchFormId").value==""){

   btn_change_UnEdit(6);
   btn_change_UnEdit(5);
   }else{
    btn_change_UnEdit(4);
     var iframe=findFrame("customerDispatchFormList");
	iframe.refleshFrame();
   }

    Calendar.setup(
              {
	              inputField : "appointment", // ID of the input field
	              ifFormat : "%Y-%m-%d %H:%M", // the date format
	              button : "appointmentImageBtn", // ID of the button
	              align          :    "Tl",           // alignment (defaults to "Bl")
			      singleClick    :    true,
			      showsTime      :    true
              }
       );

</script>
</html>